export function useResetPwd(apikey: string) {
  const loading = useLoading()
  const newPassword = ref('')
  const resetVisible = ref(false)
  async function resetDone(row) {
    loading.open()
    const { error, success, password } = await useRequest(apikey, { uuid: row.uuid }) as any
    loading.close()
    if (success) {
      resetVisible.value = true
      newPassword.value = password
    }
    else {
      if (error.code === 'ID.2000') {
        ElNotification.info('MFA 验证')
      }
      else {
        ElNotification({
          type: 'error',
          message: `密码重置失败${error.details}`,
        })
      }
    }
  }
  return {
    newPassword,
    resetVisible,
    resetDone,
  }
}
